Skip to main content

Security

Overview (C4 Component)

Black-box description of components

ComponentResponsibilityProvided Interface(s)Consumed Interface(s)
AuthenticationControllerPublic REST endpoints /v1/auth/login, /refresh, /logout.OpenAPI REST
AuthenticationServiceVerifies password, issues access & refresh JWT, persists token rows, revokes old tokens.Spring service APIUserRepository, TokenRepository, JwtTokenProvider
JwtTokenProviderStateless creation & validation of HS-256 JWT; handles custom “typ = refresh” claim.Java util classTokenRepository (black-list lookup)
JwtAuthenticationFilterRuns before every request, extracts Bearer, calls JwtTokenProvider, builds Spring Authentication.Servlet FilterJwtTokenProvider, UserDetailsService
CustomLogoutHandler/v1/auth/logout – marks both access & refresh tokens as logged-out in DB.Spring LogoutHandlerJwtTokenProvider, TokenRepository, UserRepository
AuthorizationHelperHigh-level helper used from service layer, e.g. isEsStaff(), isProvider(), isQuoteAuthor(nr)Java helperCurrentUserService, QuoteRepository
CurrentUserServiceSingle source of truth for current User / AuthInfo.Java serviceUserRepository, SecurityContext
RestSecurityConfigConfigures Spring Security: stateless, CORS, JWT filter, exception handlers.Spring SecurityFilterChain beanJwtAuthenticationFilter, CustomLogoutHandler
RestAuthenticationEntryPointReturns JSON 401, clears context.Spring AuthenticationEntryPoint
RestAccessDeniedHandlerReturns JSON 403 on authorization failures.Spring handler
UserRepository / RoleRepository / PrivilegeRepository / TokenRepositoryStandard Spring-Data JPA persistence.Spring-Data repository interfacesMySQL via Hibernate
Entities (User, Role, Privilege, Token)Domain data model for authentication & authorization.JPA entities

Important internal interfaces

NameSignature / ProtocolNotes
loginPOST /v1/auth/login – body LoginRequest200 OK LoginResponseReturns access-token & refresh-token
refreshTokenPOST /v1/auth/refresh – body { refreshToken }200 OK AuthTokenRequires valid & not-blacklisted refresh token.
logoutPOST /v1/auth/logout – header Authorization: Bearer <access> & X-Refresh-TokenCustomLogoutHandler black-lists all active tokens of the user, returns 204 No Content.
JWT BearerAuthorization: Bearer <accessToken>Every secured endpoint → JwtAuthenticationFilterSecurityContext.
403 handlerAny Spring AccessDeniedException → JSON body {status:403, error:"Forbidden", ...}Implemented by RestAccessDeniedHandler.
401 handlerInvalid / expired JWT → JSON body {status:401, error:"Unauthorized", ...}Implemented by RestAuthenticationEntryPoint.